package cn.stylefeng.guns.modular.audit;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.entity.Order;
import cn.stylefeng.guns.service.OrderRepository;
import cn.stylefeng.guns.sys.modular.consts.model.params.SysConfigParam;
import cn.stylefeng.guns.sys.modular.consts.service.SysConfigService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by  huirong on 2020-03-24
 */

@Controller
@RequestMapping("/audit")
public class AuditController extends BaseController {

    private String PREFIX = "/audit";

    @Autowired
    private OrderRepository orderRepository;


    @Autowired
    private SysConfigService sysConfigService;

    @RequestMapping("/count")
    public Long findOne(){
        return orderRepository.count();
    }



    @RequestMapping("")
    public String index() {
        long count = orderRepository.count();
        return PREFIX + "/audit.html";
    }


    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(@RequestParam(value = "condition", required = false) String condition) {

        Order order=new Order();
        order.setCityCode("0571");

        Example example=Example.of(order);
        Pageable pageable=PageRequest.of(0,3);

        Page page = orderRepository.findAll(example, pageable);

        LayuiPageInfo pageInfo = new LayuiPageInfo();
        pageInfo.setCount(orderRepository.count());
        pageInfo.setData(page.getContent());

        return pageInfo;
    }

}
